/*
 * @Author: your name
 * @Date: 2020-12-08 13:32:28
 * @LastEditTime: 2021-04-29 23:10:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /bridge-tunnel-ui/src/main.js
 */
import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets
// element-ui
import Element from 'element-ui'
import './assets/styles/element-variables.scss'
// ant design
import AntElement from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App'
import store from './store'
import router from './router'
import permission from './directive/permission'

import './assets/icons' // icon
import './permission' // permission control
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";

import { getLocalStorage, setLocalStorage } from '@/utils/index'
import { getCookie, setCookie, removeCookie } from '@/utils/auth'
import moment from 'moment'//导入文件
moment.locale('zh-cn')
Vue.prototype.$moment = moment

// 全局方法挂载
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree

Vue.prototype.getLocalStorage = getLocalStorage
Vue.prototype.setLocalStorage = setLocalStorage

Vue.prototype.getCookie = getCookie
Vue.prototype.setCookie = setCookie
Vue.prototype.removeCookie = removeCookie

Vue.prototype.msgSuccess = function (msg) {
  this.$message.success(
    msg,
    2,
  )
}

Vue.prototype.msgError = function (msg) {
  this.$message.error(
    msg,
    2
  )
}

Vue.prototype.msgInfo = function (msg) {
  this.$message.info(
    msg,
    2
  )
}

Vue.use(permission)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.use(AntElement)

// 添加实例方法 $action
Vue.prototype.$action = async function(name, param) {
  try {
    const result = await this.$store.dispatch(name, param)
    return result
  } catch (error) {
    return false
  }
}
Vue.prototype.$uploadUrl = 'https://oncorine.xgichina.cn'

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
